<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/3/15 0015
 * Time: 20:59
 */

//混合协议多端口监听
$http = new Swoole\Http\Server('0.0.0.0', 9502);
$http->set([
    'pack_max_length' => 1024 * 1024 * 2,
    'worker_num' => 2,
    // 'upload_tmp_dir'=>__DIR__."/upload",
    // 'document_root' =>__DIR__,
    // 'enable_static_handler' => true
]);
$server_port = $http->addlistener("127.0.0.1", 9503, SWOOLE_SOCK_TCP);
$server_port->set([

]);
$http->on('request', function ($request, $response) {
    $response->end("<h1>Hello Swoole. #" . rand(1000, 9999) . "</h1>");
});
$server_port->on('receive', function ($server, int $fd, int $reactor_id, string $data) {
    var_dump($server->getClientInfo);
    var_dump($data);
});
$http->start();